Servo 3 Click
Servo 3 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Oct 2025.
- Type : PWM type
Software Support
Example Description
This example demonstrates the use of the Servo 3 Click board for controlling the angle of servo motors. The board is capable of driving multiple servos, and the example illustrates how to change the angle of all connected servos simultaneously within a defined range.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Servo3
Example Key Functions
- servo3_cfg_setup This function initializes Click configuration structure to initial values.
void servo3_cfg_setup(servo3_cfg_t *cfg)
Servo 3 configuration object setup function.
Servo 3 Click configuration object.
Definition servo3.h:222
- servo3_init This function initializes all necessary pins and peripherals used for this Click board.
err_t servo3_init(servo3_t *ctx, servo3_cfg_t *cfg)
Servo 3 initialization function.
Servo 3 Click context object.
Definition servo3.h:198
- servo3_set_angle This function sets the servo angle for a specific channel or all channels.
err_t servo3_set_angle(servo3_t *ctx, uint8_t ch_num, uint8_t angle)
Servo 3 set angle function.
- servo3_update_output This function updates the PWM output values for all channels by writing them to the device.
void servo3_update_output(servo3_t *ctx)
Servo 3 update output function.
Application Init
Initializes the logger module and configures the Servo 3 Click board. The PWM communication is established, and the device is prepared for controlling the servos.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( PWM_ERROR ==
servo3_init( &servo3, &servo3_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define SERVO3_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition servo3.h:183
void application_init(void)
Definition main.c:35
Application Task
Gradually changes the angle of all connected servo motors from a minimum to a maximum value, and then back to the minimum, creating a sweeping motion. The current angle is logged during each update.
{
static int8_t step = 1;
log_printf( &logger, "All channels angle: %u\r\n\n", ( uint16_t ) angle );
angle += step;
{
step = -step;
angle += step;
}
{
step = -step;
angle += step;
}
}
#define SERVO3_ANGLE_MAX
Definition servo3.h:140
#define SERVO3_CHANNEL_ALL
Definition servo3.h:157
#define SERVO3_ANGLE_MIN
Servo 3 angle and channel setting.
Definition servo3.h:139
void application_task(void)
Definition main.c:65
Note
Ensure that the servo motors are properly connected to the Servo 3 Click board and are compatible with the specified angle range such as the SG90 Micro Servo motors.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.